<template>
  <div class="sample-tutorial" id="app">
    <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread">
      <gc-worksheet></gc-worksheet>
    </gc-spread-sheets>
  </div>
</template>

<script>
import "@grapecity-software/spread-sheets-vue";
import GC from "@grapecity-software/spread-sheets";
import '@grapecity-software/spread-sheets-resources-zh';
import '@grapecity-software/spread-sheets-io';
import "./sheetStyle.css";

GC.Spread.Common.CultureManager.culture("zh-cn");
window.GC = GC;

export default {
  name: "sheet",
  created() {

  },
  methods: {
    getSheet: function () {

    },
    initSpread: function (spread) {
      this.spread = spread;

      this.axios.post('/jmreport/exportAllExcelStream', {
        "excelConfigId": "1005272615327846400",
        "queryParam": {"pageNo": "1", "pageSize": 10, "currentPageNo": "1", "currentPageSize": 10}
      }, {responseType: 'arraybuffer'}).then(res => {

        let blob = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});

        let file = new File([blob], "example.xlsx", {
          type: blob.type,
        });

        this.file = file;

        this.spread.import(file,
          function () {
          }, function () {
          }, this.saveOptions);

      })
    },
  },
  data() {
    return {
      fileList: [],
      file: null,
      autoGenerateColumns: false,
      spread: null,
      selectedFile: null,
      saveOptions: {
        openMode: 0,
        includeStyles: true,
        includeFormulas: false,
        frozenColumnsAsRowHeaders: false,
        frozenRowsAsColumnHeaders: false,
        fullRecalc: false,
        dynamicReferences: true,
        calcOnDemand: false,
        includeUnusedStyles: true,
        incrementalLoading: false,
        encoding: "UTF-8",
        rowDelimiter: "\r\n",
        columnDelimiter: ","
      },
    };
  },
  mounted() {
  }
}
</script>

<style scoped>
.sample-tutorial {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.sample-spreadsheets {
  width: 100%;
  height: 100%;
}
</style>
